package com.esun.util.webviewchromeclient;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.esun.ui.R;

/**
 * @ClassName: CustomAlertDialog
 * @Description: 自定义AlertDialog，捕获js弹出的"提交"Dialog
 * @author: Kael gaojian@500wan.com
 * @date: 2012-7-11 下午3:40:22
 * 
 */
public class CustomAlertDialog extends Dialog {

	private Button mButton;
	private TextView mTextView;
	private CharSequence mMessage;
	private View.OnClickListener mListener;

	/**
	 * @param context
	 * @param theme
	 */
	public CustomAlertDialog(Context context) {
		super(context, R.style.dialog);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_yinlian_submitorder_failed);
		mButton = (Button) findViewById(R.id.yinlian_submitorder_dialog_btn_ok);
		mTextView = (TextView) findViewById(R.id.yinlian_submitorder_dialog_tv_msg);
		mButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				CustomAlertDialog.this.dismiss();
			}
		});
	}

	@Override
	protected void onStart() {
		mTextView.setText(mMessage);
		if (mListener != null) {
			mButton.setOnClickListener(mListener);
		}
	}

	public void setMessage(CharSequence message) {
		this.mMessage = message;
	}

	public void setOnButtonClickListener(View.OnClickListener l) {
		this.mListener = l;
	}

}